import request from '@/utils/request';
import { xlsxHost } from '@/utils/utils';

function paramsStringHandler(params: any) {
  var paramsString = '?'
  for (var k in params) {
    paramsString += `${k}=${params[k]}&`
  }
  return paramsString.substr(0,paramsString.length-1)
}

export async function queryRule(params?: any) {
  return request('/app-admin/outsourcing/activityPlay/list', {
    params,
  });
}

// select2相关接口
// 查学生(昵称 + 手机号)
export async function selectStudent(key?:string) {
  return request('/app-admin/iqidao/user/searchStudent', {
    params: {
      key
    }
  });
}


// export async function selectStudent(params?: { key?:string}) {
//   return request('/app-admin/outsourcing/activity/searchUser', {
//     params: {
//       ...params,
//       group:1
//     }
//   });
// }

export async function queryInfo(params?: any) {
  return request('/app-admin/outsourcing/activity/info', {
    params,
  });
}

export async function selectActivity(params?: { key?:string}) {
  return request('/app-admin/outsourcing/activity/select', {
    params: {
      ...params,
      group:1
    }
  });
}

export async function userPlayExport(params: {
  activityId: string;
  uid?:string
} ) {

  return Promise.resolve(xlsxHost +'/app-admin/outsourcing/activityPlay/export'+paramsStringHandler(params))
}
